import java.util.*;
import java.sql.*;

public
class LocalTableOsoba extends Vector
{
	public String IMIE = "";
	public String NAZWISKO = "";
	public String ADRES = "";
	public String TELEFON = "";
	public String EMAIL = "";
	public int id = -1;
	
	protected int currentRow = -1;

	public LocalTableOsoba()
	{
		super();
	}
	public void first()
	{
		currentRow = 0;
		fill(currentRow);
	}
	public void last()
	{
		currentRow = this.size() - 1;
		fill(currentRow);
	}
	public void next()
	{
		if (currentRow < this.size() - 1){
			fill(++currentRow);
		}
	}
	public void previous()
	{
		if(currentRow > 0){
			fill(--currentRow);
		}
	}
	public void fill(int index)
	{
		TableOsobaRow tor;
		try{
			tor = (TableOsobaRow) this.elementAt(index);
		}
		catch(ArrayIndexOutOfBoundsException e){
			return;
		}
		this.IMIE = tor.IMIE;
		this.NAZWISKO = tor.NAZWISKO;
		this.ADRES = tor.ADRES;
		this.TELEFON = tor.TELEFON;
		this.EMAIL = tor.EMAIL;
		this.id = tor.id;
	}
	public void refresh(ResultSet rs)
	{
		clear();
		String imie;
		String nazwisko;
		String adres;
		String telefon;
		String email;
		int id;
		try{
			while(rs.next()){
				TableOsobaRow tor = new TableOsobaRow();
			
				imie = rs.getString("IMIE");
				nazwisko = rs.getString("NAZWISKO");
				adres = rs.getString("ADRES");
				telefon = rs. getString("TELEFON");
				email = rs.getString("EMAIL");
				id = rs.getInt("id");

				if (adres == null){
					adres = "<brak danych>";
				}
				if (telefon == null){
					telefon = "<brak danych>";
				}
				if (email == null){
					email = "<brak danych>";
				}

				tor.IMIE = imie;
				tor.NAZWISKO = nazwisko;
				tor.ADRES = adres;
				tor.TELEFON = telefon;
				tor.EMAIL = email;
				tor.id = id;

				this.add(tor);
			}
		}
		catch(SQLException e){
		}
		first();
	}
	public void clear()
	{
		this.removeAllElements();
	}
}
